<!-- 供应商资料管理 - 综合表单页面 -->
<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />

    <ex_super_table_page v-bind="option" ref="SuperTablePage" >
    </ex_super_table_page>
  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';

import emitOnFunction from '@/mixin/emit-on-function';
let emitKey = 'srm>supplier_manage'
export default {
  title: "label_srm_supplier_data_management",
  components: {},
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],
  data() {
    return {
      option: {
        search: {
          model: [
            { key: 'supplierCode', label: 'label_srm_supplier_code', },
            { key: 'supplierName', label: 'label_srm_supplier_name', },
            { key: 'supplierType', label: 'label_srm_supplier_type', type: 'select', enum: 'SrmSupplierTypeEnum' },
            { key: 'status', label: 'label_status', type: 'select', enum: 'IsAvailableStatusEnum' },
            { key: 'contactName', label: 'label_srm_supplier_contact_name', },
          ],
        },
        action: [
          {
            label: 'label_srm_supplier_add', 
            auth:'srm_supplier_manage_edit',
            attrs: { icon: "el-icon-plus" }, click: () => {
              this.$router.push({ path: '/page/srm/supplier/supplier_operate', query: { emitKey } })
            }
          },
        ],
        table: {
          url: "/srm-api/supplier/SupplierRpc/selectPage.json",
          model: this.init_table_model(),
        },
      },


    };
  },
  methods: {
    option_table_model() {
      return [
        {
          type: 'expandDesc', 'width': 100,
          expandDesc: {
            ...this.$defaultDescAttrs,
            model: [],
          },
        },
        { key: 'supplierCode', label: 'label_srm_supplier_code', 'min-width': 130, 'show-overflow-tooltip': true, },
        { key: 'supplierName', label: 'label_srm_supplier_name', 'min-width': 130, 'show-overflow-tooltip': true, },
        { key: 'supplierType', label: 'label_srm_supplier_type', width: 130, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$enumShow(v, "SrmSupplierTypeEnum"), },

        { key: 'status', label: 'label_status', 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$enumShow(v, "IsAvailableStatusEnum"), },
        { key: 'contactName', label: 'label_srm_supplier_contact_name', width: 130, 'show-overflow-tooltip': true, },
        { key: 'contactPhone', label: 'label_srm_supplier_contact_phone', width: 130, 'show-overflow-tooltip': true, },
        { key: 'notes', label: 'label_remark', width: 130, 'show-overflow-tooltip': true, },
        {
          type: 'operate', width: 170, operate: [
            {
              label: 'label_edit',
            auth:'srm_supplier_manage_edit',
              
              click: (row) => {
                this.$router.push({ path: '/page/srm/supplier/supplier_operate', query: { id: row.id, emitKey, edit: true } })
              }
            },
            {
              label: "IsAvailableStatusEnum__ENABLE", 
              auth:'srm_supplier_manage_disable',
              type: 'confirm-button', url: '/srm-api/supplier/SupplierRpc/updateStatus.json',
              message: 'label_sure_to_enable_supply', buttonClass: "button_text_success", confirmButtonType: 'success',
              if: row => !row.status || row.status == 'DISABLED',
              params: (row) => { return { id: row.id, status: 'ENABLE' } }, done: ['reload', 'tip']
            },
            {
              label: "IsAvailableStatusEnum__DISABLED", 
              auth:'srm_supplier_manage_disable',
              type: 'confirm-button', url: '/srm-api/supplier/SupplierRpc/updateStatus.json',
              message: 'label_sure_to_disable_supply', buttonClass: "button_text_danger", confirmButtonType: 'danger',
              if: row => row.status == 'ENABLE',
              params: (row) => { return { id: row.id, status: 'DISABLED' } }, done: ['reload', 'tip']
            }
          ],
        }
      ]
    },
  }
};

</script>
<style></style>
